Skip to content

fix(install): programmatically clean gga clone dir to avoid collision#961

Open
decode2 wants to merge 1 commit into
Gentleman-Programming:mainfrom
decode2:fix/issue-31-reinstall-temp-dir-collision
Open

fix(install): programmatically clean gga clone dir to avoid collision#961
decode2 wants to merge 1 commit into
Gentleman-Programming:mainfrom
decode2:fix/issue-31-reinstall-temp-dir-collision

Conversation

@decode2

@decode2 decode2 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the GGA agent installation collision issue where \git clone\ fails because the target temporary directory \gentleman-guardian-angel\ already exists and is not empty from a previous install attempt.

Problem

When reinstalling or upgrading, the installer clones GGA into the temporary directory \gentleman-guardian-angel. If a previous installation attempt left files in that directory, \git clone\ fails with exit code 128:
\
fatal: destination path 'C:\Users\user\AppData\Local\Temp\gentleman-guardian-angel' already exists and is not an empty directory.
\`n

Solution

Programmatically clean the destination directory before cloning by calling \os.RemoveAll()\ inside
esolveGGAInstall\ at resolution time. This ensures the target directory is completely gone before the clone starts, while maintaining compatibility with the existing shell cleanup commands asserted in the unit tests.

Closes #31

Summary by CodeRabbit

  • Bug Fixes
    • Improved install cleanup handling so temporary files and directories are removed more reliably before installation steps run.
    • Reduced redundant cleanup commands in the Linux package flow and added earlier cleanup for the Windows flow, helping avoid leftover install artifacts.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 40a5b9ee-667b-4fb3-8d0b-ddf42d01ba22

📥 Commits

Reviewing files that changed from the base of the PR and between 0e15d84 and 99010b8.

📒 Files selected for processing (1)
  • internal/installcmd/resolver.go

📝 Walkthrough

Walkthrough

resolveGGAInstall now performs Go-side cleanup of existing temporary directories before assembling install commands for the apt/pacman/dnf and winget paths.

Changes

Installer temp cleanup

Layer / File(s) Summary
Pre-cleanup before command sequence
internal/installcmd/resolver.go
resolveGGAInstall removes the temp directory in Go for the apt/pacman/dnf path and removes the winget clone destination before building the returned command sequence.

Sequence Diagram(s)

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main fix: cleaning the GGA clone directory programmatically to avoid reinstall collisions.
Linked Issues check ✅ Passed The PR addresses the linked install collision by removing the existing clone directory before cloning; the backup-menu items are separate scope.
Out of Scope Changes check ✅ Passed No clear out-of-scope code changes are present; the edits stay focused on pre-cleaning install temp directories before cloning.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label Jul 9, 2026

@Alan-TheGentleman Alan-TheGentleman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent is right but I don't think this fixes #31 as shipped. The Windows branch already had a shell-level cleanup with -ErrorAction SilentlyContinue when the issue was filed, so the likely root cause is a removal that fails silently (locked file, AV handle, permissions), and this adds a second cleanup that fails silently in exactly the same way: the os.RemoveAll error is discarded. If removal fails, git clone reproduces the identical error.

Three items before this can move: surface or handle the RemoveAll error instead of discarding it (return it, log it, or retry), add a behavior-level test that creates a stale non-empty gentleman-guardian-angel directory and asserts it is actually gone after resolution (today the tests only compare the returned command strings), and reconsider doing the deletion inside resolveGGAInstall. That function is a pure resolver called from tests and any future dry-run path; deleting at resolution time is an undocumented side effect, and the existing table test now touches real OS temp dirs on every run. Executing the cleanup as part of the returned command sequence, or at execution time with an injectable path, keeps the resolver pure and the tests hermetic.

Push the update and I'll re-review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error reinstalling agent: existing temp directory causes git clone failure + backups menu select not working

2 participants